package com.example.zy5_project_jetpack.mvp.model;

import android.os.Build;
import android.util.Log;

import com.example.zy5_project_jetpack.Manager.RetrofitManager;
import com.example.zy5_project_jetpack.mvp.view.Bean.HomeBean;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class ModelData {
    public void requestData(final CallBackData callBackData) {
        ApiService apiService = RetrofitManager.getInstance().getApiService(ApiService.class);
        apiService.getHomeInfo().enqueue(new Callback<HomeBean>() {
            @Override
            public void onResponse(Call<HomeBean> call, Response<HomeBean> response) {
                List<HomeBean.DataBeanX.DataBean> data = response.body().getData().getData();
                Log.e("TAG", "onResponse: " + "M层"+data.get(0).getActivityText());
                callBackData.onSuccessData(data);
                //trtry
            }

            @Override
            public void onFailure(Call<HomeBean> call, Throwable t) {
                callBackData.onError(t.getMessage());
            }
        });
    }
}
